package com.chen.controller;

import com.chen.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/request")
public class ControllerRequest {

    //基本数据
    @RequestMapping("/test1")
    public void test1(String username,String password){
        System.out.println(username);
        System.out.println(password);
    }

    //对象
    @RequestMapping("/test2")
    public void test2(User user){
        System.out.println(user);
    }

    //请求体(@RequestBody)
    @RequestMapping("/test3")
    public void test3(@RequestBody String body){
        System.out.println("请求体：" + body);
    }

    //当前请求参数名与方法参数名不一致时（@requestParam）
    @RequestMapping("/test4")
    public void test4(@RequestParam("username") String name, String password){
        System.out.println(name);
        System.out.println(password);
    }

    //数组
    @RequestMapping("/test5")
    public void test5(String[] love){
        System.out.println(Arrays.asList(love));
    }

    //集合
    @RequestMapping("/test6")
    public void test6(@RequestBody List<User> userList){
        System.out.println(userList);
    }

}
